package top.xiangqifu.springboot2.user.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import top.xiangqifu.springboot2.user.base.BaseDataResult;
import top.xiangqifu.springboot2.user.base.BasePageResult;
import top.xiangqifu.springboot2.user.base.BaseResult;
import top.xiangqifu.springboot2.user.base.PageBean;
import top.xiangqifu.springboot2.user.entity.TbUser;
import top.xiangqifu.springboot2.user.entity.TbUserInfo;
import top.xiangqifu.springboot2.user.service.UserInfoService;
import top.xiangqifu.springboot2.user.vo.UserInfo;

import java.util.List;

@RestController
@RequestMapping("/userinfo")
@RequiredArgsConstructor
@Api(tags = "用户附加信息相关接口")
public class UserInfoController {

    private final UserInfoService userInfoService;

    @ApiOperation(value ="查询用户列表",notes = "查询用户列表功能接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "username",value = "登录用户名",dataTypeClass = String.class ,required = true),
    })
    @GetMapping("")
    public BasePageResult<List<TbUser>> getUserInfo(PageBean pageBean, TbUser user) {
        return userInfoService.queryAll(pageBean,user);
    }

    @ApiOperation(value ="添加用户附加信息",notes = "添加用户附加信息功能接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "nickname",value = "用户姓名",dataTypeClass = String.class ,required = true),
            @ApiImplicitParam(name = "sex",value = "性别，m：男，f：女，n：保密",dataTypeClass = String.class ,required = true),
            @ApiImplicitParam(name = "email",value = "邮箱",dataTypeClass = String.class ,required = true),
            @ApiImplicitParam(name = "phone",value = "手机号",dataTypeClass = String.class ,required = true),
            @ApiImplicitParam(name = "qq",value = "qq号码",dataTypeClass = String.class ,required = true),
            @ApiImplicitParam(name = "wechat",value = "微信号码",dataTypeClass = String.class ,required = true),
            @ApiImplicitParam(name = "img",value = "头像的url地址",dataTypeClass = String.class ,required = true),
            @ApiImplicitParam(name = "info",value = "用户简介",dataTypeClass = String.class ,required = true),
            @ApiImplicitParam(name = "token",value = "用户token",dataTypeClass = String.class ,required = true),
    })
    @PutMapping("")
    public BaseResult updateInfo(@RequestBody TbUserInfo tbUserInfo){
        return userInfoService.updateInfo(tbUserInfo);
    }
}
